package com.repair.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.repair.entity.ForumComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ForumCommentMapper extends BaseMapper<ForumComment> {
    
    @Select("SELECT fc.*, u.username " +
            "FROM forum_comment fc " +
            "LEFT JOIN user u ON fc.user_id = u.id " +
            "WHERE fc.post_id = #{postId} AND fc.status = 1 " +
            "ORDER BY fc.create_time ASC")
    List<ForumComment> getCommentList(@Param("postId") Long postId);
    
    @Select("SELECT fc.*, u.username " +
            "FROM forum_comment fc " +
            "LEFT JOIN user u ON fc.user_id = u.id " +
            "WHERE fc.parent_id = #{parentId} AND fc.status = 1 " +
            "ORDER BY fc.create_time ASC")
    List<ForumComment> getReplyList(@Param("parentId") Long parentId);
} 